<template>
	<view>
		<view style="margin:10upx 30upx 0 30upx;box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.04);">
			<!-- #ifdef MP-WEIXIN -->
			<ad :unit-id="mp_bannerAD" v-if="mp_bannerAD !=''"></ad>
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<ad :adpid="app_bannerAD" v-if="app_bannerAD !=''"></ad>
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<home-banner :banners="banners"></home-banner>
			<!-- #endif -->
		</view>
		<home-default :datasa="listData"></home-default>
		<uni-load-more :status="status" :content-text="contentText" />
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		debounce
	} from '@/utils/common.js'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				listData: [],
				last_id: 0,
				reload: true,
				status: 'more'
			}
		},
		computed: {
			contentText() {
				return {
					contentdown: this.$t('loadmore.down'),
					contentrefresh: this.$t('loadmore.refresh'),
					contentnomore: this.$t('loadmore.nomore')
				}
			}
		},
		onLoad(e) {
			if (e.selectIndex) {
				this.selectIndex = e.selectIndex * 1
			}
			this.status = 'more';
			this.getList();
			this.banners = uni.getStorageSync("config").banner
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: this.$t('usermenu.love')
			});
		},
		methods: {
			detail(vid, mid) {
				var fxpid = 0
				if (uni.getStorageSync("userinfo")) {
					fxpid = uni.getStorageSync("userinfo").id
				}
				uni.navigateTo({
					url: '/pages/client/tuan/detail?vid=' + vid + '&mid=' + mid + '&fxpid=' + fxpid
				})
			},
			getList: debounce(async function () {
				console.log(211111);
				let data = {};
				var limit = 10;
				if (this.last_id > 0) {
					this.status = 'loading';
					data.offset = this.last_id * limit;
				}
				data.limit = limit
				data.token = uni.getStorageSync("userinfo").token;
				let [err, res] = await this.$httpas.get('/api/video/wdxh', data);
				if (res.data.rows.length > 0) {
					let list = res.data.rows;
					this.listData = this.reload ? list : this.listData.concat(list);
					this.reload = false;
					this.last_id = this.last_id + 1;
					if (res.data.total <= this.last_id * limit) {
						this.status = '';
					} else {
						this.status = 'more'
					}
				} else {
					this.status = '';
				}
			},500)

		}
	}
</script>

<style>
	.integral-mall-goods {
		width: 100%;
		height: 280rpx;
		background: #F2F2F2;
		border-radius: 16upx;
	}

	.user-not-vip {
		width: 100%;
		height: 80rpx;
		background: #FDF6EC;
		border-radius: 40rpx;
		border: 2rpx solid #EFC381;
		text-align: center;
		line-height: 76rpx;
		font-size: 24rpx;
		color: #000000;
		font-weight: bold;
	}


	.tuan-product-l {
		width: 150rpx;
		height: 200rpx;
		border-radius: 16rpx;
		background: #F2F2F2;
	}

	.tuan-product-r {
		width: calc(100% - 150rpx);
	}

	.btn-vip-adviser {
		width: 150rpx;
		height: 60rpx;
		border-radius: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		/* font-weight: 600; */
		background: #FF6600;
		color: #FFFFFF;
	}

	.search-result {
		padding-top: 10px;
		padding-bottom: 20px;
		text-align: center;
	}

	.search-result-text {
		text-align: center;
		font-size: 14px;
		color: #666;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 0px;
	}

	.uni-mt-10 {
		margin-top: 10px;
	}
</style>